package com.fm.util;

import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

public class ConnectionUtil {
    public static Connection getConnection() throws IOException, TimeoutException {
        //1.创建连接⼯⼚
        ConnectionFactory factory = new ConnectionFactory();
        //2.在⼯⼚对象中设置MQ的连接信息(ip,port,virtualhost,username,password)
        factory.setHost("1.12.230.41");
        factory.setUsername("admin");
        factory.setPassword("admin");
        //3.通过⼯⼚对象获取与MQ的链接
        return factory.newConnection();
    }
}